package com.shang.consumer.demo;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

/**
 * @ClassName KafkaConsumer
 * @Description TODO
 * @Author Larry
 * @Date 2020/12/29 14:16
 * @Version 1.0
 */
@Slf4j
@Component
public class KafkaConsumer {

    @KafkaListener(groupId = "group02",topics = "topic02")
    public void onMessage(ConsumerRecord<String,Object> record, Acknowledgment acknowledgment, Consumer<?, ?> consumer){
        log.info("消费端接受消息：" + record.value());
        acknowledgment.acknowledge();
    }
}
